<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人主页</title>

    <link rel="stylesheet" type="text/css" href="/static/css/resources/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/stylesheets/index.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/stylesheets/personal.css"/>
    <script type="text/javascript" src="/static/js/resources/jquery.min.js"></script>
    <script src="/static/js/resources/bootstrap.min.js"></script>
    <script src="/static/js/resources/bootstrapValidator.js"></script>
    <script type="text/javascript" src="/resources/ueditor.config.js"></script>
    <script type="text/javascript" src="/resources/ueditor.all.js"></script>

</head>
<body> 

<!--头部导航-->
<div class="nav">
    <div class="nav-box">
        <div class=".col-md-2 logo"></div>
        <span class="logo-txt">SC Blog</span>

        <div class=".col-md-4 search">
            <form action="/search">
                <input type="text" name="search" class="search-box" placeholder="搜索..."/>
                <a href="javascript:void(0);" class="search-icon glyphicon glyphicon-search">
                    <button id="search-btn" style="position: absolute;border: none;opacity: 0;width: 100%;height: 100%" class=" glyphicon glyphicon-search" type="submit"></button>
                </a>
            </form>
        </div>
        <div class=".col-md-6 nav-item">
            <a href="/index">
                <span class="glyphicon glyphicon-home icon"></span>
                <span class="index">首页</span>
            </a>
            <a href="/personalCenter">
                <span class="glyphicon glyphicon-user icon"></span>
                <span class="index" th:text="${session.user.getNickname()}">火火Viann</span>
            </a>
            <a href="/loginOut">
                <span class="index">退出登录</span>
            </a>
        </div>

        <!--发布新微博btn-->
        <a href="javascript:void(0);" class="public-news" id="public-news">
            <span class="glyphicon glyphicon-edit public"></span>
        </a>

    </div>
</div>

<div class="container-box">
    <div class="cont-top">
        <img src="/static/images/test/1.jpg" class="background-img">

        <div class="head-box">
            <img th:src="${user.getImgUrl()}" class="user-head">
        </div>
        <span class="user-name" th:text="${user.getNickname()}">火火</span>
        <span class="introduction" th:text="${user.getResume()}"></span>
    </div>

    <div class="col-md-4 cont-rit">
        <!--部分个人信息-->
        <div class="personal">

            <div class="info">
                <div class="item">
                    <a href="javascript:void(0);" id="follow-btn">
                        <span class="num" th:text="${user.getAttentionUsers().size()}">112</span>
                        <span class="text">关注</span>
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0);" id="fans-btn">
                        <span class="num" th:text="${user.getFollowUsers().size()}">234</span>
                        <span class="text">粉丝</span>
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0);" id="news-btn">
                        <span class="num" th:text="${user.getBlogs().size()}">96</span>
                        <span class="text">微博</span>
                    </a>
                </div>
            </div>
        </div>

        <!-- 个人资料 -->
        <div class="per-info">
            <span class="head">个人资料</span>

            <ul class="info-box">
                <li>
                    <span class="tit">昵称:</span>
                    <span class="info" th:text="${user.getNickname()}">111</span>
                </li>
                <li>
                    <span class="tit">邮箱:</span>
                    <span class="info" th:text="${user.getEmail()}"></span>
                </li>
                <li>
                    <span class="tit">性别:</span>
                    <span class="info" th:text="${user.getSex()}"></span>
                </li>
                <li>
                    <span class="tit">电话:</span>
                    <span class="info" th:text="${user.getPhone()}"></span>
                </li>
                <li>
                    <span class="tit">简介:</span>
                    <span class="info" th:text="${user.getResume()}"></span>
                </li>
            </ul>

            <div class="edit">
                <a href="javascript:void(0);" class="info-edit" id="info-edit-btn">编辑个人资料 ></a>
            </div>
        </div>
    </div>


    <div class="col-md-8 cont-left" id="cont-box">

        <!--富文本部分-->
        <div class="editor" id="editor-box">
            <div class="text-editor">
                <textarea name="后台取值的key" id="myEditor"></textarea>
            </div>
            <a href="javascript:void(0);" class="publish" id="publish-btn">发布</a>
            <a href="javascript:void(0);" class="publish close" id="colse-btn">取消</a>
        </div>

        <!--自己发布的微博-->
        <div class="fri-news" id="fri-news" data-name="news">

            <div class="news-item" th:each="blog: ${blogPage.getContent()}">

                <div  th:if="${blog.isHot()}" class="hot-blog">
                    <span class="glyphicon glyphicon-fire"></span>
                </div>

                <a href="javascript:void(0);" class="dele-news" th:attr="data-blogId=${blog.getId()}">删除</a>

                <div class="item-top">
                    <div class="user-head">
                        <a th:href="'/personalCenter/' + ${blog.getUser().getId()}">
                            <img th:src="${blog.getUser().getImgUrl()}" class="head-img"/>
                        </a>
                    </div>
                    <div class="item-info">
                        <div class="user-name" th:text="${blog.getUser().getNickname()}"></div>
                        <div class="create-time" th:text="${#dates.format(blog.getCreateTime(),'yyyy-MM-dd HH:mm')}"></div>
                        <p class="text" th:utext="${blog.getContext()}"></p>
                    </div>
                </div>
                <div class="item-botm">
                    <a href="javascript:void(0);" class="comment comment-list-btn">
                        <span class="glyphicon glyphicon-pencil icon"></span>评论
                    </a>
                    <span class="cut"></span>
                    <a href="javascript:void(0);" class="good"
                       th:attr="data-blogId=${blog.getId()},data-status=${blog.isPoint(session.user.id)}">
                        <span class="glyphicon glyphicon-thumbs-up icon"></span> <span
                        th:text="${blog.isPoint(session.user.id)}?'取消点赞':'点赞'"></span> <span
                        th:text="${blog.getPoints()}"></span>
                    </a>
                </div>
                <div class="comment-list">
                    <span class="triangle"></span>

                    <div class="comment-left">
                        <a th:href="'/personalCenter/' + ${session.user.getId()}">
                            <img th:src="${session.user.getImgUrl()}" class="head">
                        </a>
                    </div>
                    <div class="comment-rit">
                        <div class="add-comment">
                            <textarea name="" class="text" th:attr="data-blogId=${blog.getId()}"></textarea>
                            <a href="javascript:void(0);" class="comment-btn">评论</a>
                        </div>
                        <div class="comment-container">

                            <div class="fri-comment" th:each="comment: ${blog.getComments()}">
                                <a th:href="'/personalCenter/' + ${comment.getUser().getId()}">
                                    <img th:src="${comment.getUser().getImgUrl()}" class="head">
                                </a>

                                <div class="info-box">
                                <span class="text" >
                                    <span class="fir-name" th:text="${comment.getUser().getNickname()}"></span>:&nbsp
                                    <span th:text="${comment.getContext()}"></span>
                                </span>
                                    <span class="create-time" th:text="${#dates.format(comment.getCreateTime(),'yyyy-MM-dd HH:mm')}"></span>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
            <ul class="pagination">
                <li class="arrow" th:unless="${blogPage.getNumber()} == 0"><a
                    th:href="'/personalCenter?page=' + ${blogPage.getNumber()}">&laquo;</a>
                </li>
                <li><a href="javascript:;">当前页面 第<span th:text="${blogPage.getNumber()+1}"></span>页</a></li>
                <li class="arrow" th:unless="${blogPage.getNumber()} == ${blogPage.getTotalPages() -1}"><a
                    th:href="'/personalCenter?page=' + ${blogPage.getNumber() + 2}">&raquo;</a>
                </li>
                <li><a href="javascript:;">共 <span th:text="${blogPage.getTotalPages()}"></span>页</a></li>
                <li class="goto">
                    <a>
                        <form th:action="'/personalCenter/'"method="get" >
                            <span>跳转至</span>
                            <input onkeyup="value=value.replace(/[^\d]/g,'')" min="0" th:max="${blogPage.getTotalPages()}" type="number" name="page">

                            <span>页</span>
                            <button type="submit" class="btn btn-default">确认跳转</button>
                        </form>
                    </a>
                </li>
            </ul>
        </div>
        <!--自己发布的微博end-->


        <!--粉丝列表-->
        <div class="fri-list follow-list" id="fans-list" data-name="fans">
            <span class="title">粉丝</span>
            <div class="item" th:each="aUser : ${user.getFollowUsers()}">
                <div class="img-box">
                    <a th:href="'/personalCenter/' + ${aUser.getId()}">
                        <img th:src="${aUser.getImgUrl()}" class="head">
                    </a>
                </div>
                <div class="info">
                    <span class="name" th:text="${aUser.getNickname()} + ' --- ' +${session.user.relationship(aUser.getId())}">名字这个粉丝</span>

                    <div class="num-box">
                        <span class="num-item">
                            关注:
                            <span class="num" th:text="${aUser.getAttentionUsers().size()}"></span>
                        </span>
                        <span class="num-item">
                            粉丝:
                            <span class="num" th:text="${aUser.getFollowUsers().size()}"></span>
                        </span>
                        <span class="num-item">
                            微博:
                            <span class="num" th:text="${aUser.getBlogs().size()}"></span>
                        </span>
                    </div>
                    <div class="introduction">
                        简介:
                        <span class="intro" th:text="${aUser.getResume()}"></span>
                    </div>
                </div>
            </div>
        </div>
        <!--粉丝列表end-->

        <!--关注的人列表-->
        <div class="fri-list fans-list" id="follow-list" data-name="follow" >
            <span class="title">关注</span>
            <div class="item" th:each="aUser : ${user.getAttentionUsers()}">
                <div class="img-box">
                    <a th:href="'/personalCenter/' + ${aUser.getId()}">
                        <img th:src="${aUser.getImgUrl()}" class="head">
                    </a>
                </div>
                <div class="info">
                    <span class="name" th:text="${aUser.getNickname()} + ' --- ' +${session.user.relationship(aUser.getId())}">名字这个粉丝</span>
                    <div class="num-box">
                        <span class="num-item">
                            关注:
                            <span class="num" th:text="${aUser.getAttentionUsers().size()}"></span>
                        </span>
                        <span class="num-item">
                            粉丝:
                            <span class="num" th:text="${aUser.getFollowUsers().size()}"></span>
                        </span>
                        <span class="num-item">
                            微博:
                            <span class="num" th:text="${aUser.getBlogs().size()}"></span>
                        </span>
                    </div>
                    <div class="introduction">
                        简介:
                        <span class="intro" th:text="${aUser.getResume()}"></span>
                    </div>
                </div>
            </div>
        </div>
        <!--关注的人列表end-->

        <!--修改个人信息-->

        <div class="edit-per-info" id="edit-info">
            <span class="title">编辑个人资料</span>

            <div class="item-box">
                <div class="item fixed">
                    <span class="tit">邮箱:</span>
                    <span class="email" th:text="${user.getEmail()}"></span>
                </div>

                <form class="head-form" action="/changeUserImg" method="post" enctype="multipart/form-data">
                    <div class="item fixed">
                        <span class="tit">头像:</span>
                        <input type="file" name="img" class="head">
                    </div>
                    <button type="submit" class="btn-item">确定</button>
                </form>



                <form id="password-form" class="form-horizontal" action="/changeUserPassword" method="post">
                    <div class="item form-group">
                        <span class="tit">旧密码:</span>
                        <input type="password" class="form-control edit old-password" name="oldPassword">
                    </div>
                    <div class="item form-group">
                        <span class="tit">新密码:</span>
                        <input type="password" class="form-control edit new-password" name="newPassword">
                    </div>
                    <div class="item form-group">
                        <span class="tit">确认新密码:</span>
                        <input type="password" class="form-control edit new-password2" name="newPassword2">
                    </div>
                    <button type="submit" class="btn-item">确定</button>
                </form>


                <form id="edit-form" class="form-horizontal" method="post" th:action="@{/changeUser}" th:object="${user}">
                    <div class="item sex fixed  form-group">
                        <span class="tit">性别:</span>
                        <label>
                            <input type="radio" name="sex" value="0">男
                        </label>
                        <label>
                            <input type="radio" name="sex" value="1">女
                        </label>
                        <label>
                            <input type="radio" name="sex" value="2">保密
                        </label>
                    </div>
                    <div class="item form-group">
                        <span class="tit">昵称:</span>
                        <input type="text" class="form-control edit nick-name" name="nickname" th:value="${user.getNickname()}">
                    </div>
                    <div class="item form-group">
                        <span class="tit">电话:</span>
                        <input type="text" class="form-control edit phone" name="phone" th:value="${user.getPhone()}">
                    </div>

                    <div class="item introduction form-group">
                        <span class="tit">个人简介:</span>
                        <textarea name="" class="introduction" name="resume" th:text="${user.getResume()}"></textarea>
                    </div>
                    <button type="submit" class="btn-item">确定</button>
                </form>
            </div>
        </div>

        <!--修改个人信息end-->


    </div>

</div>

<!--返回顶部-->
<a href="javascript:void(0);" id="to-top" class="to-top">
    <span class="glyphicon glyphicon-arrow-up top-icon"></span>
</a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" th:include="pages/common/modal :: modal"></div>
<script type="text/javascript" th:inline="javascript">
    var session_user = new Object();
    session_user.nickname = /*[[${session.user.getNickname()}]]*/;
    session_user.imgUrl = /*[[${session.user.getImgUrl()}]]*/;
    session_user.imgUrl = /*[[${session.user.getImgUrl()}]]*/;
</script>
<script type="text/javascript">
    // 对Date的扩展，将 Date 转化为指定格式的String
    // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，
    // 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
    // 例子：
    // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
    // (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "H+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };
</script>
<!--修改个人资料验证-->
<script type="text/javascript">
    jQuery(document).ready(function () {
        $('#edit-form')
                .bootstrapValidator({
                    message: '这个值无效',
                    //live: 'submitted',
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        nickname: {
                            message: '无效的昵称',
                            validators: {
                                notEmpty: {
                                    message: '昵称不能为空'
                                },
                                stringLength: {
                                    min: 1,
                                    max: 8,
                                    message: '昵称长度大于1小于8'
                                }
                            }
                        },
                        sex:{
                            validators: {
                                notEmpty: {
                                    message: '性别不能为空'
                                }
                            }
                        },
                        phone: {
                            validators: {
                                notEmpty: {
                                    message: '手机号不能为空'
                                },
                                stringLength: {
                                    min: 11,
                                    max: 11,
                                    message: '手机号长度不对'
                                },
                                regexp: {
                                    regexp: /^[0-9]+$/,
                                    message: '手机号应该为数字'
                                }
                            }
                        }
                    }
                });

        $('#password-form')
                .bootstrapValidator({
                    message: '这个值无效',
                    //live: 'submitted',
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        oldPassword: {
                            validators: {
                                notEmpty: {
                                    message: '密码不能为空'
                                },
                                stringLength: {
                                    min: 5,
                                    max: 30,
                                    message: '密码长度大于5小于30'
                                }
                            }
                        },
                        newPassword: {
                            validators: {
                                notEmpty: {
                                    message: '密码不能为空'
                                },
                                stringLength: {
                                    min: 5,
                                    max: 30,
                                    message: '密码长度大于5小于30'
                                }
                            }
                        },
                        newPassword2: {
                            validators: {
                                notEmpty: {
                                    message: '密码不能为空'
                                },
                                identical: {
                                    field: 'newPassword',
                                    message: '两次密码应该一致'
                                },
                                stringLength: {
                                    min: 5,
                                    max: 30,
                                    message: '密码长度大于5小于30'
                                }
                            }
                        }
                    }
                })
    });
</script>


<script type="text/javascript">

    /*本页面tab点击切换模块*/
    $(function() {
        var cont_box = $("div#cont-box"),
                fri_news = cont_box.find("div#fri-news"),
                follow_list = cont_box.find("div#follow-list"),
                fans_list = cont_box.find("div#fans-list"),
                edit_info = cont_box.find("div#edit-info"),
                follow_btn = $("a#follow-btn"),
                fans_btn = $("a#fans-btn"),
                news_btn = $("a#news-btn"),
                edit_btn = $("a#info-edit-btn"),
                open_editor = $("a#public-news"),
                editor_box = $("div#editor-box");

        follow_btn.bind("click", function (){
            cont_box.children().fadeOut(200);
            follow_list.fadeIn(200);
        });
        fans_btn.bind("click", function (){
            cont_box.children().fadeOut(200);
            fans_list.fadeIn(200);
        });
        news_btn.bind("click", function (){
            cont_box.children().fadeOut(200);
            fri_news.fadeIn(200);
        });
        edit_btn.bind("click", function (){
            cont_box.children().fadeOut(200);
            edit_info.fadeIn(200);
        });
        open_editor.bind("click", function (){
            cont_box.children().fadeOut(200);
            fri_news.fadeIn(200);
        });
    });

    /*从首页跳转至个人主页显示对应模块*/
    $(function(){
        var hash = location.hash,
                hash_name = hash.replace("#",""),
                cont_box = $("div#cont-box"),
                cont_item = cont_box.children();

        cont_item.each(function (){
            var $this = $(this),
                    name = $this.data("name");

            if(hash_name == name){
                cont_item.hide();
                $this.show();
                hash_name.replace("");
            }
        });
    });
</script>


<script type="text/javascript">

    /*发布微博, 添加评论*/
    $(function () {
        var fri_news = $("div#fri-news"),
                news_item = fri_news.find("div.news-item");

        function init(e) {
            var $this = $(e),
                    comment_list = $this.find("div.comment-list"),
                    add_comment = comment_list.find("textarea.text"),
                    comment_val = add_comment.val(),
                    add_comment_btn = comment_list.find("a.comment-btn"),
                    comment_container = $this.find("div.comment-container"),
                    comment_list_btn = $this.find("a.comment-list-btn");

            /*添加评论框获得和失去焦点*/
            add_comment.bind({
                focus: function () {
                    add_comment.addClass("onfocus");
                },
                blur: function () {
                    add_comment.removeClass("onfocus");
                }
            });

            /*添加评论*/
            add_comment_btn.bind("click", function () {
                var new_comment = comment_list.find("textarea.text"),
                        new_val = new_comment.val(),
                        blogId = new_comment.attr('data-blogId');
                $.ajax({
                    url: "/addComment",
                    data: {
                        "blogId": blogId,
                        "context" : new_val
                    },
                    contentType : "application/x-www-form-urlencoded; charset=utf-8",
                    type: 'POST',
                    success: function(data){
                        good_btn.addClass("active");
                        status = true;
                    }
                });
                comment_container.append(get_comment(new_val));
            });

            function get_comment(new_val) {
                return "<div class='fri-comment'>" +
                    "<img src='" + session_user.imgUrl + "' class='head'>" +
                    "<div class='info-box'><span class='text'><span class='fir-name'> " + session_user.nickname + "</span>: " + new_val + "</span>" +
                    "<span class='create-time'> " + new Date().Format('yyyy-MM-dd HH:mm') + "</span></div>" +
                    "</div>";
            }

            /*评论框所有评论隐藏显示*/
            if (comment_container.children('.fri-comment').length > 0) {
                comment_list.show();
            }
            else {
                comment_list.hide();
            }

            comment_list_btn.bind("click", function () {
                comment_list.toggle();
            });


            /*点赞功能*/
            var good_btn = $this.find("a.good");

            function pointClick() {

                var _this = $(this);
                var status = _this.attr("data-status");
                var blogId = _this.attr('data-blogId');
                _this.unbind("click");
                _this.bind("click", function () {
                    alert('请稍等');
                });
                if (status == 'false') {
                    $.ajax({
                            url: "/pointBlog",
                            data: {
                                "blogId": blogId
                            },
                            type: 'POST',
                            success: function (data) {
                                _this.unbind("click");
                                _this.bind('click', pointClick);
                                console.info(data);
                                if (data.isSuccess) {
                                    good_btn.addClass("active");
                                    status = true;
                                    _this.attr("data-status", true);
                                    _this.children().get(1).innerHTML = "取消点赞";
                                    var num = _this.children().get(2).innerHTML;
                                    _this.children().get(2).innerHTML = parseInt(num) + 1;

                                }
                                else {
                                    alert(data.reason);
                                }
                            }
                        }
                    );
                }
                else if (status == 'true') {
                    $.ajax({
                        url: "/unPointBlog",
                        data: {
                            "blogId": blogId
                        },
                        type: 'POST',
                        success: function (data) {
                            _this.unbind("click");
                            _this.bind('click', pointClick);
                            console.info(data);
                            if (data.isSuccess) {
                                good_btn.removeClass("active");
                                status = false;
                                _this.attr("data-status", false);
                                _this.children().get(1).innerHTML = "点赞";
                                var num = _this.children().get(2).innerHTML;
                                _this.children().get(2).innerHTML = parseInt(num) - 1;
                            }
                            else {
                                alert(data.reason);
                            }
                        }
                    });
                }
            }

            good_btn.bind("click",pointClick);


            /*删除微博*/
            var dele_btn = $this.find("a.dele-news"),
                    blogId = dele_btn.attr('data-blogId');

            dele_btn.bind("click",function (){
                $.ajax({
                    url: "/deleteBlog",
                    data: {
                        "blogId": blogId
                    },
                    type: "POST",
                    success: function(data) {
                        if (data.isSuccess) {
                            window.location = "/personalCenter";
                        }
                        else{
                            alert(data.reason);
                        }
                    }
                });
            });


        }

        news_item.each(function(i,e){
            init(e); //针对循环出的当前一个对象e ??
        });




        /*富文本, 发布新状态*/
        /*富文本初始化*/
        var editor = new UE.ui.Editor();
        editor.render("myEditor");
        //1.2.4以后可以使用一下代码实例化编辑器
        //UE.getEditor('myEditor')

        var myeditor = $("textarea#myEditor"),
                publish_btn = $("a#publish-btn"),
                fri_news = $("div#fri-news"),
                open_editor = $("a#public-news"),
                close_editor = $("a#colse-btn"),
                editor_box = $("div#editor-box");

        open_editor.bind("click", function () {
            editor_box.fadeIn(200);
        });

        close_editor.bind("click", function () {
            editor_box.fadeOut(200);
        });

        publish_btn.bind("click", function () {

            var content = UE.getEditor('myEditor').getContent();    //UEditor取得内容Html的方法

            function publish_info(info) {
                return "<div class='news-item'><div class='item-top'>" +
                        "<div class='user-head'><img src='/static/images/test/head.jpg' class='head-img'/></div>" +
                        "<div class='item-info'><div class='user-name'>AAA</div>" +
                        "<div class='create-time'>2016-4-16</div>" +
                        "<p class='text'>" + info + "</p></div></div>" +

                        "<div class='item-botm'>" +
                        "<a href='javascript:void(0);' class='comment comment-list-btn'>" +
                        "<span class='glyphicon glyphicon-pencil icon'></span>评论</a><span class='cut'></span>" +
                        "<a href='javascript:void(0);' class='good' data-status=false>" +
                        "<span class='glyphicon glyphicon-thumbs-up icon'></span>点赞</a><span class='cut'></span>" +
                        "<a href='javascript:void(0);' class='report'>" +

                        "<div class='comment-list'><span class='triangle'></span>" +
                        "<div class='comment-left'><img src='/static/images/test/head.jpg' class='head'></div>" +
                        "<div class='comment-rit'><div class='add-comment'><textarea name='' class='text'></textarea>" +
                        "<a href='javascript:void(0);' class='comment-btn'>评论</a></div>" +
                        "<div class='comment-container'></div></div></div></div>";
            }

            $.ajax({
                url: "/publishBlog",
                data: {
                    "context": content
                },
                type: 'POST',
                success: function (data) {
                    var news = data;
                    if(news.isSuccess) {
                        window.location = "/personalCenter";
                        //新发布的微博显示为第一个
//                        fri_news.prepend(publish_info(content));
//                        //页面已加载完,新发布的微博无法取到,所以需要重新循环,取得父元素的第一个子元素也就是新发布的微博.
//                        init(fri_news.children('div.news-item')[0]);
                    }
                    else {
                        alert(news.reason);
                    }
                }
            })

        });


    });

    /*返回顶部*/
    $(function () {
        var to_top = $("a#to-top"),
                body = $("body,html"),
                body_scrolltop = body.scrollTop(),
                isTop = true;

        if (body_scrolltop > 0) {
            to_top.show();
        }
        else {
            to_top.hide();
        }

        to_top.bind("click", function () {
            body.animate({scrollTop: 0}, 200);
            to_top.hide(0, function () {

            });
        });

        $(window).scroll(function () {
            var body_scrolltop = body.scrollTop();

            if (body_scrolltop > 0 && isTop == true) {
                isTop = false;
                to_top.fadeIn(200);
            }
            else if (body_scrolltop <= 0) {
                isTop = true;
                to_top.fadeOut(200);
            }
        });
    });




</script>

</body>
</html>